﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Pool.CollectionPool`2
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Collections.Generic;

#nullable disable
namespace UnityEngine.Pool
{
  /// <summary>
  ///   <para>A Collection such as List, HashSet, Dictionary etc can be pooled and reused by using a CollectionPool.</para>
  /// </summary>
  public class CollectionPool<TCollection, TItem> where TCollection : class, ICollection<TItem>, new()
  {
    internal static readonly ObjectPool<TCollection> s_Pool = new ObjectPool<TCollection>((Func<TCollection>) (() => new TCollection()), actionOnRelease: (Action<TCollection>) (l => l.Clear()));

    public static TCollection Get() => CollectionPool<TCollection, TItem>.s_Pool.Get();

    public static PooledObject<TCollection> Get(out TCollection value)
    {
      return CollectionPool<TCollection, TItem>.s_Pool.Get(out value);
    }

    public static void Release(TCollection toRelease)
    {
      CollectionPool<TCollection, TItem>.s_Pool.Release(toRelease);
    }
  }
}
